package cn.lingyangwl.agile.auth.model.rqrs.oauth2;

import cn.lingyangwl.agile.auth.oauth2.model.*;
import cn.lingyangwl.agile.model.constants.*;
import cn.lingyangwl.agile.model.enums.*;
import cn.lingyangwl.agile.model.module.auth.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * 构建token上下文请求
 * @author shenguangyang
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class TokenContextBuildReq {
    @NotNull(message = ValidationCons.NOT_EMPTY)
    private RegisteredClient client;

    @NotNull(message = ValidationCons.NOT_EMPTY)
    private GrantTypeEnum grantType;

    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    private String loginId;

    /**
     * 如果用户首次采用第三方登录且管理员没有开启自动绑定功能, 则userId是空, 需要用户进行绑定操作
     */
    private Long userId;

    /**
     * 登录的账号, 可为第三方openId, 本地用户名/手机号/邮箱等登录
     */
    private String loginAccount;

    private String openId;

    private Map<String, Object> tokenClaims;

    /**
     * 终端
     * @see TerminalEnum
     */
    private String terminal;
}
